const Mock = require('mockjs')

const data = Mock.mock({
  'list|100': [{
    id: '@increment',
    'pic|1': ['http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180607/5ac1bf58Ndefaac16.jpg',
      'http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5a9d248cN071f4959.jpg'],
    name: '@first @last',
    price: '@integer(60, 5000)',
    productSn: '@increment',
    'brandName|1': ['华为', '小米'],
    sort: '@integer(0, 100)',
    create_time: '@datetime',
    sale: '@integer(60, 5000)'
  }]
})

module.exports = [
  {
    url: '/product/list',
    type: 'get',
    response: config => {
      const { pageNum,pageSize } = config.query
      const mockList = data.list.filter(item => {
        return true
      })
      const pageList = mockList.filter((item, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1))
      return {
        code: 20000,
        data: {
          total: mockList.length,
          list: pageList
        }
      }
    }
  }

]
